function [pa_v_pb] = pera_vs_perb(a,b)

nopts = length(a);

% making sure a values < b values
%  - switch if a > b
ck_ratio = mean(a./b);
if(ck_ratio > 1)
    val_1 = b;
    val_2 = a;
else
    val_1 = a;
    val_2 = b;
end

pa_v_pb = zeros(nopts,2);
for k = 1:nopts
    
    v1 = val_1(k);
    p2_at_p1 = find(val_2(:,1)<=v1,1,'last');
    if(isempty(p2_at_p1))
        p2_at_p1 = 0;
    end
    pa_v_pb(k,1) = k;
    pa_v_pb(k,2) = p2_at_p1;

end

pa_v_pb = 100*pa_v_pb/nopts;

% switch back to % a vs % b, regardless of initial order (above)
if(ck_ratio>1)
   temp = pa_v_pb;
   pa_v_pb(:,1) = temp(:,2);
   pa_v_pb(:,2) = temp(:,1);
end